package com.googlecode.garbagecan.beanutils;

import org.apache.commons.beanutils.BeanUtils;

import java.util.Calendar;

public class BeanUtilsSample {
	public static void main(String[] args) throws Exception {
		SampleBean bean = new SampleBean();
		BeanUtils.setProperty(bean, "strProperty", "str");
		BeanUtils.setProperty(bean, "integerProperty", null);// Take care, will get 0.
		BeanUtils.setProperty(bean, "intProperty", 0);
		BeanUtils.setProperty(bean, "longProperty", 1234567890);
		BeanUtils.setProperty(bean, "dateProperty", Calendar.getInstance().getTime());

		System.out.println("String property: " + BeanUtils.getProperty(bean, "strProperty"));
		System.out.println("Integer Property: " + BeanUtils.getProperty(bean, "integerProperty"));
		System.out.println("int Property: " + BeanUtils.getProperty(bean, "intProperty"));
		System.out.println("long Property: " + BeanUtils.getProperty(bean, "longProperty"));
		System.out.println("Date Property: " + BeanUtils.getProperty(bean, "dateProperty"));

		System.out.println("String property: " + bean.getStrProperty());
		System.out.println("Integer Property: " + bean.getIntegerProperty());
		System.out.println("int Property: " + bean.getIntProperty());
		System.out.println("long Property: " + bean.getLongProperty());
		System.out.println("Date Property: " + bean.getDateProperty());
	}
}
 